from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver import ChromeOptions
from time import sleep
class Public:

    # 创建 WebDriver 对象，指明使用chrome浏览器驱动
    option=ChromeOptions()
    option.add_experimental_option('excludeSwitches',['enable-automation'])
    option.add_argument("--disable-blink-features=AutomationControlled")
    option.add_argument('--ignore-certificate-errors')
    option.add_argument('--log-level=1')
    option.add_experimental_option("detach", True)
    wd = webdriver.Chrome(service=Service(r'D:\soft\selenium\chromedriver.exe'),options=option)
    script='''object.defineProperty(navigator,'webdriver',{undefinedget:()=>undefined}'''
    wd.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument",{"source":script})

    # 调用WebDriver 对象的get方法 可以让浏览器打开指定网址
    wd.get('https://******************/#/login')

    #窗口最大化
    wd.maximize_window()

# def open_browser():
#     # 创建 WebDriver 对象，指明使用chrome浏览器驱动
#     option=ChromeOptions()
#     option.add_experimental_option('excludeSwitches',['enable-automation'])
#     option.add_argument("--disable-blink-features=AutomationControlled")
#     option.add_experimental_option("detach", True)
#     wd = webdriver.Chrome(service=Service(r'D:\soft\selenium\chromedriver.exe'),options=option)
#     script='''object.defineProperty(navigator,'webdriver',{undefinedget:()=>undefined}'''
#     wd.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument",{"source":script})
#
#     # 调用WebDriver 对象的get方法 可以让浏览器打开指定网址
#     wd.get('https://***********.cn/')
#
#     #窗口最大化
#     wd.maximize_window()

p=Public()